package com.books.controllers;

import com.books.models.tb_books;
import com.books.services.BookService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author 刘志伟
 * @create 2022/9/21 10:50
 */
@Controller
@Slf4j
@RequestMapping("/books")
public class BooksController {

    @Autowired
    private  BookService bookService;

    @RequestMapping(value = "/list",method = RequestMethod.GET)
    public String getBookList(Model model){

        List<tb_books> list = bookService.getBooks("walt","thinkinjava","zh-cn");
        model.addAttribute("bookinfo",list.get(0));
        return "list";
    }
}
